
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>计算器实现</title>
    <link href="./css/index.css" rel="stylesheet" />
</head>

<body>
<div id="app">
    <div class="input-num">
        <button @click="sub">-</button>
        <span>{{message}}</span>
        <button @click="add">+</button>
    </div>
</div>
<script src="./js/vue.js"></script>
<script>
    var app=new Vue({
        el:"#app",
        data:{
            message:1
        },
        methods:{
            sub:function (){
                if (this.message <= 1){
                    alert("已经是最小了")
                }else {
                    this.message = this.message - 1
                }
            },
            add:function (){
                if (this.message >= 10){
                    alert("已经是最大了")
                }else {
                    this.message = this.message + 1
                }
            }
        }
    })
</script>
</body>

</html>